package com.zoe.controller;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * @Author Zoe.Zhang
 * @Date: 2021/07/03
 * @Description $description
 */
@WebServlet(name = "WelServlet", urlPatterns = "/api/welcome")
public class ApiWelServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String user = (String) request.getSession().getAttribute("user");
        PrintWriter writer = response.getWriter();
        writer.println("欢迎" + user);
        writer.write("<a href='/api/welcome'>带斜杠</a>");
        writer.write(" <a href='api/welcome'>不带斜杠</a>");
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
